package domain

import (
	"errors"
	"github.com/lab-online/internal/user/constant"
	"github.com/lab-online/internal/user/entity"
)

func (d *Domain) SearchUser(userEntity entity.UserEntity) ([]entity.UserEntity, error) {
	users, err := d.repository.GetUsers(userEntity)
	switch {
	case err == nil:
		return users, nil
	case errors.Is(err, constant.DBErrUserNotFound):
		return nil, constant.RESTErrUserNotFound
	default:
		return nil, err
	}
}
